/**	\author    coidgen 0.9.2
	\version    (0.0 build 7)
	\date      
	\brief     
*/



// Service header info (for version checking),  ! DO NOT CHANGE !
static const char COID_bin_data[] =
"060005000000302E392E3209000000312E342028342E3029460C0000AA2D304400000000000000000000000007000000"
"0100000001000000070000004D7564506F72740000000024000000206163636570746F725F706F7274203233206E6F6C"
"6F675F73797374656D5F63616C6C7300000000050000000500000005000000FFFFFFFF040000006F7063640000000000"
"0000000000800000000004000000726561640000000001000000FFFFFFFF1100000064796E61727261793C6368617273"
"74723E000000000000000000000208000000000007200000000000000000FFFFFFFF040000006F706364000000000000"
"0000000080000000000400000073656E640100000001000000FFFFFFFF0D000000636F6E737420636861727374720000"
"00000000000000001108000000000007200000000000000000FFFFFFFF040000006F7063640000000000000000000080"
"000000000500000066657463680200000002000000FFFFFFFF1100000064796E61727261793C636861727374723E0000"
"00000000000000000208000000FFFFFFFF04000000766F69640000000000000000020002440000000000012000000000"
"00000000FFFFFFFF040000006F70636400000000000000000000800000000007000000736574696E666F030000000100"
"0000FFFFFFFF04000000766F6964000000000000000001000144000000000001200000000000000000FFFFFFFF040000"
"006F70636400000000000000000000800000000005000000666C7573680400000001000000FFFFFFFF17000000636F6E"
"73742064796E61727261793C636861727374723E00000000000000000000110800000000000120000000000000000001"
"FFFFFFFF040000006F7063640000000000000000000080000000000E0000006163636570745F636F6E6E656374050000"
"800000000000008700000000000000000001FFFFFFFF040000006F706364000000000000000000008000000000150000"
"006163636570745F636F6E6E6563745F73686172656406000080000000000000870000000000000000000001FFFFFFFF"
"040000006F706364000000000000000000008000000000160000006163636570745F6E65745F636F6E6E656374696F6E"
"731100008102000000FFFFFFFF090000006E6574536F636B6574000000000000000001000104000000FFFFFFFF040000"
"0075696E7400000000000000000000010000000000208720000000000000000001FFFFFFFF040000006F706364000000"
"0000000000000080000000000E0000006163636570745F64657374726F79020000800000000000008700000000000000"
"000001FFFFFFFF040000006F706364000000000000000000008000000000150000006163636570745F73746172747570"
"5F706172616D73FFFF008001000000FFFFFFFF0D000000636D645F696E74657266616365000000000000000000000108"
"000000000087200000000000000000000000010027011700000000000000"
;
//*/


#include "coid/comm/interfnc.h"
#include "mudport.h"
#include "coid/comm/metastream/metastream.h"


namespace coid {


static inline const char ** COID_OUT_ARGS(const char ** from) {
	while( *from ) from++;
	return ++from;
}

typedef ServiceDescriptor::MethodDesc MethodDesc;
#define COID_MethodDesc_constructor(S,I,F)         MethodDesc( S[0], S[1], &S[2], COID_OUT_ARGS(&S[2]), I, F )
#define COID_MethodDesc_constructor_NotImpl        MethodDesc( NULL, NULL, NULL, NULL, 0, 0 )



typedef void (MudPort::*coid_fnc)();

/// fake function, should never be called:
static void coid_throw() {throw ersFE_EXCEPTION;}

/// we need type cast in case there are 2 or more methods with the same name
#define COID_DISPATCH_CREATE_HOOK(M,i,t,tc) \
	if( i < coid_fnc_count ) { \
		if( (coid_flags[i] & COID_MudPort_method_desc[i].flags & MethodDesc::xACCESS_MODE) ) \
			coid_fnc_table[t] = (coid_fnc) (tc) &MudPort::M; \
		else *(void **) &coid_fnc_table[t] = (void *) coid_throw; \
	}


#define COID_DISPATCH_CREATE_CALLER_HOOK(M,i,t) \
	if( i < coid_fnc_count ) { \
		if( (coid_flags[i] & COID_MudPort_method_desc[i].flags & MethodDesc::xACCESS_MODE) ) \
			coid_fnc_table[t] = (coid_fnc) &DISPATCH_CALLER_MudPort_0_0::M; \
		else *(void **) &coid_fnc_table[t] = (void *) coid_throw; \
	}






/// functions:
uint COID_MudPort_0_0_get_method_id( const token & name );
opcd COID_MudPort_0_0_dispatch( InstanceData * _coid_inst_data, uint _coid_fnc_id, binstream& _coid_bstr, metastream* coid_meta=0 );
metastream& COID_MudPort_0_0_getmeta();



struct DISPATCH_CALLER_MudPort_0_0
{
	void call_dispatch( binstream * b ) {
		COID_CLIENT_EXESTREAM_ARGS * a = (COID_CLIENT_EXESTREAM_ARGS *) this;
		InstanceData d;  d._object = a->obj;
		COID_MudPort_0_0_dispatch( &d, a->id, *b );
	}
};





enum {	/// command ids, format is: COID_classname_fncname_fncid
	COID_MudPort_read_0 = 0,
	COID_MudPort_send_1 = 1,
	COID_MudPort_fetch_2 = 2,
	COID_MudPort_setinfo_3 = 3,
	COID_MudPort_flush_4 = 4,

    COID_MudPort_accept_connect_5,
    COID_MudPort_accept_connect_shared_6
};



/// info about every function:
static const char * COID_MudPort_read_0_finfo[] = {"read", "opcd ", NULL, "dynarray<charstr> & str", NULL};
static const char * COID_MudPort_send_1_finfo[] = {"send", "opcd ", "const charstr & str", NULL, NULL};
static const char * COID_MudPort_fetch_2_finfo[] = {"fetch", "opcd ", NULL, "dynarray<charstr> & cmds", "void ** creature", NULL};
static const char * COID_MudPort_setinfo_3_finfo[] = {"setinfo", "opcd ", "void * creature", NULL, NULL};
static const char * COID_MudPort_flush_4_finfo[] = {"flush", "opcd ", "const dynarray<charstr> & cmds", NULL, NULL};
static const char * COID_MudPort_accept_connect_5_finfo[] = {"accept_connect", "opcd ", NULL, NULL};
static const char * COID_MudPort_accept_connect_shared_6_finfo[] = {"accept_connect_shared", "opcd ", NULL, NULL};


/// create structure that holds everything about function:
static const MethodDesc COID_MudPort_method_desc[] = {
	COID_MethodDesc_constructor( COID_MudPort_read_0_finfo, 0, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_MudPort_send_1_finfo, 1, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_MudPort_fetch_2_finfo, 2, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_MudPort_setinfo_3_finfo, 3, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_MudPort_flush_4_finfo, 4, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_MudPort_accept_connect_5_finfo, 2147483653, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fLOG_CALL ),
	COID_MethodDesc_constructor( COID_MudPort_accept_connect_shared_6_finfo, 2147483654, MethodDesc::fACCESS_MODE_DIRECT | MethodDesc::fACCESS_MODE_INTERPROCESS | MethodDesc::fACCESS_MODE_REMOTE | MethodDesc::fLOG_CALL )
};



static const char * COID_dependencies_MudPort[] = {

	NULL
};


/// ServiceDescriptor:
static ServiceDescriptor COID_descriptor_MudPort;



/// dispatch stores function tables for all 'direct' clients with different minor versions here
class COID_register_MudPort_0_0
{
	struct table {
		uint ver;
		coid_fnc * tbl;
	};
	dynarray<table>	_tables;

public:
//	comm_mutex_rw	_mx;
	comm_mutex	_mx;
   const void* (*dummyreg)();

	COID_register_MudPort_0_0() {
		COID_descriptor_MudPort._version.set( "", 0, 0, 7 );
		COID_descriptor_MudPort._coid_version = COID_VERSION;
		COID_descriptor_MudPort._name = "MudPort";
		COID_descriptor_MudPort._shortname = "MudPort";
		COID_descriptor_MudPort._info = "";
		COID_descriptor_MudPort._dependencies = COID_dependencies_MudPort;
		COID_descriptor_MudPort._nmeth = 5;
		COID_descriptor_MudPort._methflags = COID_MudPort_method_desc;
		COID_descriptor_MudPort._flags = ServiceDescriptor::fALLOW_DIRECT_ACCESS | ServiceDescriptor::fALLOW_INTERPROCESS_ACCESS | ServiceDescriptor::fALLOW_REMOTE_ACCESS | ServiceDescriptor::fAUTONOMOUS;
		COID_descriptor_MudPort._acceptor_port = (uint) 23;
		COID_descriptor_MudPort._bin_svc_data = COID_bin_data;
		COID_descriptor_MudPort.get_method_id = COID_MudPort_0_0_get_method_id;
		COID_descriptor_MudPort.dispatch = COID_MudPort_0_0_dispatch;
		COID_descriptor_MudPort._fnc_get_meta = COID_MudPort_0_0_getmeta;
#ifdef _DEBUG
		COID_descriptor_MudPort._flags |= ServiceDescriptor::fDEBUG;
#endif
		_mx.set_name( "COID_register_MudPort_0_0" );
		INTERFACE_REGISTER(ServiceDescriptor).add( &COID_descriptor_MudPort );
	}

	~COID_register_MudPort_0_0() {
//		MXGUARDRW( (comm_mutex_rw &) _mx );
		MXGUARD( (comm_mutex &) _mx );
		for( uint i=0; i<_tables.size(); i++ )
			delete [] _tables[i].tbl;
	}
	coid_fnc * get_table_notlocked( uint ver ) {
		for( uint i=0; i<_tables.size(); i++ )
			if( ver == _tables[i].ver ) return _tables[i].tbl;
		return NULL;
	}
	coid_fnc * get_table( uint ver ) {
//		MXGUARDRW( (const comm_mutex_rw &) _mx );		/// ==> read lock
		MXGUARD( (const comm_mutex &) _mx );
		return get_table_notlocked( ver );
	}
	void insert_table( uint ver, coid_fnc * tbl ) {
		table * t = _tables.add( 1 );	/// mutex has been locked
		t->ver = ver; t->tbl = tbl;
	}
};


// for dll linking
COID_register_MudPort_0_0 & get_COID_register_MudPort_0_0()
{
	static COID_register_MudPort_0_0 x;
	x.dummyreg = &coid_get_sdir2;    //force exporting the symbol
	x.dummyreg();
	return x;
}

//for static linking (must be called from outside to link this object)
void get_COID_register_MudPort()
{
	COID_register_MudPort_0_0();
}

static COID_register_MudPort_0_0 & COID_auto_register_variable = get_COID_register_MudPort_0_0();





metastream& COID_MudPort_0_0_getmeta()
{
    static metastream* meta = 0;
    if(meta)  return *meta;

    meta = new metastream;
    ServiceDescriptor::MethodDesc* med=0;
#define META_TD(TY)     metastream::TypeDesc< TY >::get_str(*meta)


    return *meta;
}



///////////////////////////////////////////////////////////////////////////////
opcd COID_MudPort_0_0_dispatch( InstanceData* _coid_inst_data, uint _coid_fnc_id, binstream& _coid_bstr, metastream* coid_meta )
{
	MudPort * _coid_MudPort_obj = (MudPort *) _coid_inst_data->_object;
	double _coid_MudPort_ticks = 0.0;
	binstream * _coid_log = NULL;
	opcd _coid_err_code = 0;

	switch( _coid_fnc_id ) {
		case StdDispatchMethod::CONSTRUCTOR: {
			_coid_inst_data->_object = _coid_MudPort_obj = new MudPort;
       } break;
		case StdDispatchMethod::POSTCONSTRUCTOR: {
			_coid_err_code = _coid_MudPort_obj->accept_startup_params( *_coid_inst_data->_cmdin );
		} break;
		case StdDispatchMethod::DESTRUCTOR: {
			delete _coid_MudPort_obj; _coid_inst_data->_object = NULL;
		} break;
		case StdDispatchMethod::CREATE_INTERFACE: {
			CreateInterfaceInfo* coid_iface_info;
			_coid_bstr.read_ptr(coid_iface_info);
			const uint coid_fnc_count = coid_iface_info->_nmethods;
			const uint * coid_flags = coid_iface_info->_methflags;
			coid_fnc * coid_fnc_table = get_COID_register_MudPort_0_0().get_table( coid_iface_info->_clientver.get_minor() );

			if( !coid_fnc_table ) {
				//MXGUARDRW( get_COID_register_MudPort_0_0()._mx );
				MXGUARD( get_COID_register_MudPort_0_0()._mx );
				coid_fnc_table = get_COID_register_MudPort_0_0().get_table_notlocked( coid_iface_info->_clientver.get_minor() );
				if( !coid_fnc_table ) {
					coid_fnc_table = (coid_fnc *) new char[ sizeof(coid_fnc) * (coid_fnc_count + 1) ];	/// new coid_fnc[...] would allocate pointer to 0 bytes (M$ 'feature')
					memset( coid_fnc_table, 0, (coid_fnc_count + 1) * sizeof(coid_fnc) );
					uint coid_table_index = 0;

					((CreateInterfaceInfo::t_fnc *) coid_fnc_table)[coid_table_index++] = coid_iface_info->_disconnect_interface;
					COID_DISPATCH_CREATE_HOOK( read, 0, coid_table_index++, opcd (MudPort::*)( dynarray<charstr> &  ) )
					COID_DISPATCH_CREATE_HOOK( send, 1, coid_table_index++, opcd (MudPort::*)( const charstr &  ) )
					COID_DISPATCH_CREATE_HOOK( fetch, 2, coid_table_index++, opcd (MudPort::*)( dynarray<charstr> & , void **  ) )
					COID_DISPATCH_CREATE_HOOK( setinfo, 3, coid_table_index++, opcd (MudPort::*)( void *  ) )
					COID_DISPATCH_CREATE_HOOK( flush, 4, coid_table_index++, opcd (MudPort::*)( const dynarray<charstr> &  ) )

					get_COID_register_MudPort_0_0().insert_table( coid_iface_info->_clientver.get_minor(), coid_fnc_table );
				}
			}

			_coid_bstr.acknowledge();
			_coid_bstr.write_ptr( coid_fnc_table );
			_coid_bstr.write_ptr( _coid_inst_data->_object );
			_coid_bstr.write_ptr( coid_iface_info->_mutex );
		} break;
		case StdDispatchMethod::AUTHENTIFY: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_MudPort_ticks = SINGLETON(HPTIMER).ftime();
			

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << "80000005" << ") accept_connect ( "; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_MudPort_obj->accept_connect(  );
			_coid_bstr << _coid_err_code;
			

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_MudPort_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;
		case StdDispatchMethod::AUTHENTIFY_SHARED: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_MudPort_ticks = SINGLETON(HPTIMER).ftime();
			

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << "80000006" << ") accept_connect_shared ( "; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_MudPort_obj->accept_connect_shared(  );
			_coid_bstr << _coid_err_code;
			

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_MudPort_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;
		case StdDispatchMethod::AUTHENTIFY_AUTO: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::HANDLE_NET_LOOP: {
			uint port;
			netSocket* s;
			_coid_bstr.read_ptr(s);
			_coid_bstr >> port;
			_coid_bstr.acknowledge();
			opcd e = _coid_MudPort_obj->accept_net_connections( s, port );
			_coid_bstr << e;
			_coid_bstr.flush();
			return e;
		} break;
		case StdDispatchMethod::PREDESTRUCTOR: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_MudPort_ticks = SINGLETON(HPTIMER).ftime();
			

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << "80000002" << ") accept_destroy ( "; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_MudPort_obj->accept_destroy(  );
			_coid_bstr << _coid_err_code;
			
			_coid_bstr.flush();

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_MudPort_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;
		case StdDispatchMethod::COMMAND: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::SPAWN: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;
		case StdDispatchMethod::ECHO: {
			_coid_bstr.acknowledge();
			_coid_bstr << _coid_err_code;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		} break;


		/// service-specific methods:
		case COID_MudPort_read_0: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_MudPort_ticks = SINGLETON(HPTIMER).ftime();
			
			dynarray<charstr> str;

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << COID_MudPort_read_0 << ") read ( "; *_coid_log << "?"; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_MudPort_obj->read( str );
			_coid_bstr << _coid_err_code;
			if( ! _coid_err_code ) {
				_coid_bstr << str;
			}

			_coid_bstr.flush();

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << str; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_MudPort_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;
		case COID_MudPort_send_1: {
			if( (_coid_inst_data->_flags & (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION)) == (MethodDesc::fLOG_CALL | MethodDesc::fLOG_DURATION) )
				_coid_MudPort_ticks = SINGLETON(HPTIMER).ftime();
			
			charstr str;
			_coid_bstr >> str;

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				_coid_log = &_coid_inst_data->_cmdin->post_method();
				*_coid_log << "(" << COID_MudPort_send_1 << ") send ( "; *_coid_log << str; *_coid_log << " )";
			}

			_coid_bstr.acknowledge();

			_coid_err_code = _coid_MudPort_obj->send( str );
			_coid_bstr << _coid_err_code;
			
			_coid_bstr.flush();

			if( _coid_inst_data->_flags & MethodDesc::fLOG_CALL ) {
				*_coid_log << "  -->  ("; *_coid_log << ")";
				if( _coid_inst_data->_flags & MethodDesc::fLOG_DURATION )
					*_coid_log << " [" << (SINGLETON(HPTIMER).ftime() - _coid_MudPort_ticks) * 1000 << "]";
				if( !_coid_err_code ) *_coid_log << " .. ok" << EOM;
				else *_coid_log << " .. fail: " << opcd_formatter(_coid_err_code) << EOM;
			}
			
		} break;


		default:
			_coid_bstr.acknowledge( true );
			_coid_bstr << ersNOT_IMPLEMENTED;
			_coid_bstr.flush();
			return ersNOT_IMPLEMENTED;
		break;
	}



	return _coid_err_code;
}












/// method table
static METHOD_TABLE COID_MudPort_method_table[] = {
	{"setinfo", COID_MudPort_setinfo_3},
	{"flush", COID_MudPort_flush_4},
	{NULL, UMAX},
	{NULL, UMAX},
	{"fetch", COID_MudPort_fetch_2},
	{NULL, UMAX},
	{"read", COID_MudPort_read_0},
	{"send", COID_MudPort_send_1}
};



#define COID_dispatch_method_size		(sizeof(COID_MudPort_method_table) / sizeof(METHOD_TABLE))



uint COID_MudPort_0_0_get_method_id( const token & name )
{
	hash<token> mha;
	uints idx = mha(name) % COID_dispatch_method_size;

	for( uint i=0; i<COID_dispatch_method_size; i++ ) {
		if( COID_MudPort_method_table[idx].name )
			if( name == COID_MudPort_method_table[idx].name )
				return COID_MudPort_method_table[idx].id;
		idx++;
		if( idx == COID_dispatch_method_size ) idx = 0;
	}

	return UMAX;
}


} // namespace coid
